var http = require('http')
var url = require('url')
var fs = require('fs')

let host = '127.0.0.1'
let port = 9099

function start(route, handle) {
    
    function onRequest(req, res) {
        let pathname = url.parse(req.url).pathname
        console.log('Request for' + pathname + 'received.')
        route(handle, pathname, res, req)
    }

    http.createServer(onRequest).listen(port, host)
    console.log('Server has started and listening on ' + host + ':' + port)
}

exports.start = start